
import * as commodityQuery from './mall-commodity-query/Handler';
import * as commoditySearch from './mall-commodity-search/Handler';
import * as commodityQueryById from './mall-commodity-queryById/Handler';
import * as commodityQueryCount from './mall-commondity-count/Handler'

let myHandler = function (event, context, callback, logger) {
    let operation;
    let params;

    logger.info("enter mall-commodity func with operation " + event.operation);

    operation = event.body ? JSON.parse(event.body).operation : event.operation;
    params = event.body ? JSON.parse(event.body).params : event.params;

    switch (operation) {
        case "query":
            commodityQuery.myHandler(params, context, callback, logger);
            break;
        case "search":
            commoditySearch.myHandler(params, context, callback, logger);
            break;
        case "queryById":
            commodityQueryById.myHandler(params, context, callback, logger);
            break;
        case "queryCount":
            commodityQueryCount.myHandler(params, context, callback, logger);
            break;
        default:
            callback({
                ret: { code: -1, desc: "no such function" },
            });
    }
};

module.exports.myHandler = myHandler;
